package com.aaa.web.controller.secondcar;

import com.aaa.entity.Permission;
import com.aaa.entity.secondcar.SecondCarDetailMessage;
import com.aaa.entity.secondcar.SecondCarRelatedMessage;
import com.aaa.web.commons.Result;
import com.aaa.web.commons.SecondCarVerifyQuery;
import com.aaa.web.service.secondcarservice.SecondCarVerifyService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import java.util.List;
import java.util.Map;

/**
 * @program: ${PROJECT_NAME}
 * @description: 二手车认证页面
 * @author: 许一鑫
 * @create: 9:28 2019/1/3
 **/
@Controller
@RequestMapping("/SecondCarVerifyController")
public class SecondCarVerifyController {
    /**
     * 自动注入
     */
    @Autowired
    private SecondCarVerifyService service;

    /**
     * 进入二手车认证界面
     */
    @RequestMapping("/GetSecondCarVerifyPage")
    public String getSecondCarVerifyPage(Model model) {
        List<Permission> permissionList = null;
        model.addAttribute("list", permissionList);
        return "views/webhtml/secondcar/secondverify";
    }

    /**
     * 查询所有二手车相关信息展现在认证信息栏
     */
    @RequestMapping("/GetSecondCarRelatedMessage")
    @ResponseBody
    public Map getSecondCarRelatedMessage(SecondCarVerifyQuery query) {
        Map map = service.getSecondCarRelatedMessage(query);
        return map;
    }

    /**
     * 二手车认证的详情表单
     */
    @RequestMapping("/GetSecondCarDetailMessage")
    @ResponseBody
    public List<SecondCarDetailMessage> getSecondCarDetailMessage(SecondCarRelatedMessage s) {

        List<SecondCarDetailMessage> list = service.getSecondCarDetailMessage(s);
        return list;
    }

    /**
     * 二手车认证
     */
    @RequestMapping("/VerifySecondCar")
    @ResponseBody
    public Result verifySecondCar(SecondCarDetailMessage s) {
        return service.verifySecondCar(s);
    }

    /**
     * 取消二手车门店认证
     */
    @RequestMapping("/CancelVerification")
    @ResponseBody
    public Result CancelVerification(SecondCarRelatedMessage s) {
        return service.cancelVerification(s);

    }

    /**
     * 删除二手车信息
     */
    @RequestMapping("/DeleteSecondCarMessage")
    @ResponseBody
    public String DeleteSecondCarMessage(SecondCarRelatedMessage s) {
        service.deleteSecondCarMessage(s);
        return null;
    }
}
